restaurants %>%
filter(latitude > 35.6699 & latitude < 36.6699) %>%
filter(longitude < -114.6398 & longitude > -115.6398) %>%
plot_ly(x = ~longitude, y = ~latitude, type = "scatter", mode = "markers",
alpha = 0.5,
color = ~stars, hoverinfo = 'text',
text = ~paste(name, " @", neighborhood, "\n", address, "\n", city, ", ", state, postal_code, "\n", stars, "stars on Yelp")) %>%
layout(xaxis = list(title = "Longitude"),
yaxis = list(title = "Latitude"))restaurants %>%
mutate(stars = if_else(stars == 1, "1",
if_else(stars == 1.5, "1.5",
if_else(stars == 2, "2",
if_else(stars == 2.5, "2.5",
if_else(stars == 3, "3",
if_else(stars == 4, "4",
if_else(stars == 4.5, "4.5", "5"))))))),
review_count = as.numeric(review_count)) %>%
group_by(stars) %>%
plot_ly(x = ~stars, y = ~review_count, color = ~stars, type = "bar", colors = "Set3") %>%
layout(xaxis = list(title = "Stars"),
yaxis = list(title = "Number of Reviews"))popular <- categories %>%
filter(category == "Restaurants" | category == "Food") %>%
distinct(business_id) %>%
left_join(categories, by = "business_id") %>%
filter(category %in% c("Bars", "Breakfast & Brunch", "Chinese", "Italian", "Mexican", "Chicken Wings", "Salad", "Sushi Bars", "Pizza", "Steakhouses", "Fast Food"))
restaurants %>%
select(business_id, neighborhood) %>%
inner_join(popular) %>%
distinct() %>%
group_by(neighborhood, category) %>%
tally() %>%
plotly::plot_ly(x = ~neighborhood, y = ~n, type = 'bar', color = ~category, hoverinfo = 'text',
text = ~paste(neighborhood, " has ",
n, " ", category, " restaurants.")) %>%
layout(yaxis = list(title = "Restaurants"), xaxis = list(title = "", tickangle = -45), barmode = 'stack')